//
//  User+Extension.m
//  DEMO
//
//  Created by J on 16/5/19.
//  Copyright © 2016年 J. All rights reserved.
//

#import "User+Extension.h"
#import <objc/runtime.h>

@implementation User (Extension)
+ (void)load{
    
    swizzleMethod([self class], @selector(name), @selector(name2));
}
- (void)name{
    NSLog(@"%s",__func__);
}
- (void)name2{
    [self name2];
    NSLog(@"%s",__func__);
}

- (void)performselector{
    NSLog(@"%s",__func__);
}
void swizzleMethod(Class class, SEL originalSelector, SEL swizzledSelector)   {
    Method originalMethod = class_getInstanceMethod(class, originalSelector);
    Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
    method_exchangeImplementations(originalMethod, swizzledMethod);//已测试originalSelector不存在不会崩溃
}

@end
